package com.designPattern.clone;

import javax.management.ListenerNotFoundException;

/**
 * @author mxs
 */
public class TestClone {
    public static void main(String[] args) throws CloneNotSupportedException {
        Farm farm1 = new Farm("farm1");
        Farm farm2 = (Farm) farm1.clone();
        System.out.println("farm1:"+farm1.hashCode());
        System.out.println("farm2:"+farm2.hashCode());
        System.out.println("farm1.sheep:" + farm1.sheep.hashCode());
        System.out.println("farm2.sheep:" + farm2.sheep.hashCode());
        System.out.println("farm1.sheep:"+farm1.sheep.toString());
        farm1.sheep.name = "多利羊";
        farm1.farmName = "farm2";
        System.out.println("farm2:sheep:" + farm2.farmName);
//        House house = new House(1);
//        House house2 = (House) house.clone();
//        System.out.println(house.toHashCode());
//        System.out.println(house2.toHashCode());
    }
}
